package com.wanger.swc.util.template;

import cn.hutool.core.util.IdUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @Author: wanger
 * @Date: 2024/9/23 16:40
 * @Description:
 */
@Data
@AllArgsConstructor
@Accessors(chain = true)
public class FileData {
    public FileData(String name) {
        this.name = name;
    }

    private final String id = IdUtil.fastSimpleUUID();//文件名称
    private final String name;//文件名称
    private final List<FileData> children = new ArrayList<>();//有子文件则为文件夹，没有子文件则为文件，并需要写入文件内容
    private String fileContent;//文件内容
    private boolean convertToZip = false;//是否转换为zip

    public FileData addChild(FileData child) {
        children.add(child);
        return this;
    }

    public FileData addChild(Collection<FileData> multipleChildren) {
        children.addAll(multipleChildren);
        return this;
    }

}
